//
//  NetworkService.h
//  QuXiang
//
//  Created by Duncan on 2020/6/17.
//  Copyright © 2020 NanHuaiZi. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <AFNetworking.h>

NS_ASSUME_NONNULL_BEGIN

typedef NS_ENUM(NSInteger, RequestUrlInterFace) {
    None,
    
};

typedef NSURLSessionDataTask URLSessionDataTask;
typedef NSURLSessionUploadTask URLSessionUploadTask;
typedef void(^DownloadProgressBlock)(NSProgress * _Nonnull progress);
//typedef void(^ResponSuccessBlock)(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject);
typedef void(^ResponSuccessBlock)(int code,id info,NSString *msg);
typedef void(^ResponFailBlock)(int code, id info, NSString *msg);
typedef void(^UploadProgressBlock)(NSProgress * _Nonnull uploadProgress);


@interface NetworkService : NSObject

+ (instancetype)service;

/// 设置token
- (void)setTokenWithHeader;

@property (nonatomic, strong) NSDictionary *requesFaceDict; // 接口字典
@property (nonatomic, strong) AFHTTPSessionManager           *manager;

#pragma mark ------- 下载 -------

+ (NSURLSessionDownloadTask * _Nullable)downWithUrlString:(NSString *)urlString
                                          pathString:(NSString *)pathString
                                               progress:(DownloadProgressBlock _Nullable)downloadProgress
                                                  success:(ResponSuccessBlock _Nullable)success
                                                  failure:(ResponFailBlock _Nullable)failure;

/**
 *  文件上传接口
 *
 *  @param fileData       文件data
 *  @param filePath       文件存储在沙盒路径
 *  @param name           key
 *  @param fileName       文件名
 *  @param mimeType       文件类型例如 image/jpeg
 *  @param urlStr         url
 *  @param parameters     body
 *  @param uploadProgress 进度回调
 *
 *  @return NSURLSessionUploadTask
 */
//+ (URLSessionDataTask * _Nullable)uploadWithFileData:(NSData * _Nullable)fileData
//                                            filePath:(NSString * _Nullable)filePath
//                                                name:(NSString * _Nonnull)name
//                                            fileName:(NSString * _Nonnull)fileName
//                                            mimeType:(NSString * _Nonnull)mimeType
//                                             baseUrl:(NSString * _Nullable)baseUrl
//                                              urlStr:(NSString * _Nonnull)urlStr
//                                          parameters:(NSDictionary * _Nullable)parameters
//                                            progress:(UploadProgressBlock _Nullable)uploadProgress
//                                             success:(ResponSuccessBlock _Nullable)success
//                                             failure:(ResponFailBlock _Nullable)failure;

//#pragma mark ------- PUT -------
//
//+ (URLSessionDataTask *_Nullable)putWithUrlEnumName:(RequestUrlInterFace)name
//                                           parameters:(NSDictionary * _Nullable)parameters
//                                        urlParameters:(NSDictionary * _Nullable)urlParameters
//                                              success:(ResponSuccessBlock _Nullable)success
//                                              failure:(ResponFailBlock _Nullable)failure;
//
//#pragma mark ------- DELETE -------
//
//+ (URLSessionDataTask *_Nullable)deleteWithUrlEnumName:(RequestUrlInterFace)name
//                                           parameters:(NSDictionary * _Nullable)parameters
//                                        urlParameters:(NSDictionary * _Nullable)urlParameters
//                                              success:(ResponSuccessBlock _Nullable)success
//                                              failure:(ResponFailBlock _Nullable)failure;

//#pragma mark ------- GET -------
///**
// *  GET请求接口
// *
// *  @param name          接口路径，如/path/getArticleList
// *   parameters          接口中所需要的 ? 后面的参数,不一定要拼接到url中,可以通过参数的形式传递(类似于POST)
// *   urlParameters       接口路径中所需要的拼接参数
// *   downloadProgress    接口请求数据进度的回调
// *   success             接口成功请求到数据的回调
// *  @param failure       接口请求数据失败的回调
// *
// *  @return 返回的对象中有可取消请求的API
// */
//+ (URLSessionDataTask *_Nullable)getWithUrlEnumName:(RequestUrlInterFace)name
//                                              success:(ResponSuccessBlock _Nullable)success
//                                              failure:(ResponFailBlock _Nullable)failure;
//+ (URLSessionDataTask *_Nullable)getWithUrlEnumName:(RequestUrlInterFace)name
//                                           parameters:(NSDictionary * _Nullable)parameters
//                                              success:(ResponSuccessBlock _Nullable)success
//                                              failure:(ResponFailBlock _Nullable)failure;
//+ (URLSessionDataTask *_Nullable)getWithUrlEnumName:(RequestUrlInterFace)name
//                                        urlParameters:(NSDictionary *_Nullable)urlParameters
//                                              success:(ResponSuccessBlock _Nullable)success
//                                              failure:(ResponFailBlock _Nullable)failure;
//+ (URLSessionDataTask *_Nullable)getWithUrlEnumName:(RequestUrlInterFace)name
//                                           parameters:(NSDictionary * _Nullable)parameters
//                                        urlParameters:(NSDictionary * _Nullable)urlParameters
//                                             progress:(DownloadProgressBlock _Nullable)downloadProgress
//                                              success:(ResponSuccessBlock _Nullable)success
//                                              failure:(ResponFailBlock _Nullable)failure;

#pragma mark ------- POST -------
/**
 *  POST请求接口
 *
 *  @param name     接口路径，如/path/getArticleList
 *   params         接口中所需要的拼接参数，如@{"categoryid" : @(12)}
 *   progress       接口请求数据进度的回调
 *  @param success  接口成功请求到数据的回调
 *  @param failure  接口请求数据失败的回调
 *
 *  @return 返回的对象中有可取消请求的API
 */
/// 只带url
+ (URLSessionDataTask * _Nullable)postWithUrlEnumName:(RequestUrlInterFace)name
                                    urlPathParameters:(NSDictionary *_Nullable)urlPathParameters
                                              success:(ResponSuccessBlock _Nullable)success
                                              failure:(ResponFailBlock _Nullable)failure;

/// 只带body
+ (URLSessionDataTask * _Nullable)postWithUrlEnumName:(RequestUrlInterFace)name
                                           parameters:(id _Nullable)parameters
                                              success:(ResponSuccessBlock _Nullable)success
                                              failure:(ResponFailBlock _Nullable)failure;


/// 带body
+ (URLSessionDataTask * _Nullable)postWithUrlEnumName:(RequestUrlInterFace)name
                                      urlPathParameters:(NSDictionary *_Nullable)urlPathParameters
                                             parameters:(id _Nullable)parameters
                                                success:(ResponSuccessBlock _Nullable)success
                                                failure:(ResponFailBlock _Nullable)failure;

/// 带所有
+ (URLSessionDataTask * _Nullable)postWithUrlEnumName:(RequestUrlInterFace)name
                                      urlPathParameters:(NSDictionary *_Nullable)urlPathParameters
                                   otherUrlParameters:(NSDictionary * _Nullable)otherUrlParameters
                                             parameters:(id _Nullable)parameters
                                               progress:(DownloadProgressBlock _Nullable)downloadProgress
                                                success:(ResponSuccessBlock _Nullable)success
                                                failure:(ResponFailBlock _Nullable)failure;

/// 针对于不是我们公司的api请求
+ (void)postJsonDataWithUrlString:(NSString * _Nonnull)urlString
                       parameters:(id _Nullable)parameters
                          success:(ResponSuccessBlock _Nullable)success
                          failure:(ResponFailBlock _Nullable)failure;

@end

NS_ASSUME_NONNULL_END




